<?php

!defined('IN_NOVA') && exit('Access Denied!');

class Category {

	public function __construct() {}

	public function __destruct() {}

	public function start() {
		global $db,$theme,$cache,$request;

		// 参数处理
		$theme->current_page = max( 1, $request->page );
		$theme->max_per_page = $cache->config['maxperpage'];

		$cate = $db->result( "SELECT cid FROM `" . DB_PREFIX . "category` WHERE alias='" . $request->get( 'p' ) . "'" );
		if ( $cate === FALSE || !array_key_exists( $cate , $cache->category ) ) {
			$theme->err_404();
			return;
		} else {
			$theme->title = $cache->category[$cate]['name'] . '|' . L( '_CATEGORY_' );
		}
		$theme->id = $cate;
		$theme->params = $request->get( 'p' );
		$theme->article_num = $cache->category[$cate]['articlenum'];
		$theme->load( 'index' );
	}
}
?>